<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>文本框</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
    <meta name="generator" content="www.leipi.org" />
    <link rel="stylesheet" href="/js/ueditor/formdesign/bootstrap/css/bootstrap.css">
    <!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="/js/ueditor/formdesign/bootstrap/css/bootstrap-ie6.css">
    <![endif]-->
    <!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="/js/ueditor/formdesign/bootstrap/css/ie.css">
    <![endif]-->
    <link rel="stylesheet" href="leipi.style.css">
    <script type="text/javascript" src="/js/ueditor/dialogs/internal.js"></script>
    <script type="text/javascript">
/* Thank you by  
http://www.alt-tag.com/blog/2006/02/ie-dom-bugs/ */
function createElement(type, name)
{     
    var element = null;     
    try {        
        element = document.createElement('<'+type+' name="'+name+'">');     
    } catch (e) {}   
    if(element==null) {     
        element = document.createElement(type);     
        element.name = name;     
    } 
    return element;     
}
    </script>
</head>
<body>
<div class="content">
    <table class="table table-bordered table-striped table-hover">
     <tr>
        <th><span>控件名称</span><span class="label label-important">*</span></th>
        <th><span>默认值</span> </th>
    </tr>
    <tr>
        <td><input type="text" id="orgname" placeholder="必填项"></td>
        <td><input type="text" id="orgvalue" placeholder="无则不填"></td>
    </tr>
    <tr>
        <th><span>数据校验类型</span> </th>
        <th><span>对齐方式</span> </th>
    </tr>
    <tr>
        <td>
            <select id="orgtype">
                <option value="text">普通文本</option>
                <option value="required">必填项</option>
                <option value="email">邮箱地址</option>
                <option value="float">数字</option>
                <option value="idcard">身份证号码</option>
                <option value="date">日期</option>
            </select>
        </td>
        <td>
            <select id="orgalign">
                <option value="left" >左对齐</option>
                <option value="center">居中对齐</option>
                <option value="right">右对齐</option>
            </select>
        </td>
    </tr>
    <tr>
        <th><span>&nbsp;&nbsp;&nbsp;&nbsp;长&nbsp;&nbsp;X&nbsp;&nbsp;宽&nbsp;&nbsp;&nbsp;&&nbsp;&nbsp;&nbsp;字体大小</span> </th>
        <th><span>对象name</span> </th>
    </tr>
    <tr>
        <td>
            <input id="orgwidth" type="text" value="150px" class="input-small span1" placeholder="auto"/>
            X
            <input id="orgheight" type="text" value="100%" class="input-small span1" placeholder="auto"/>
            &
            <input id="orgfontsize" type="text"  value="" class="input-small span1" placeholder="auto"/> px

        </td>
        <td><input type="text" id="orgnames"></td>
    </tr>
        <tr>
            <th><span>数据类型</span> </th>
            <th><span>只读控制参数</span> </th>
        </tr>
        <tr>
            <td>
                <select id="orgdatatype">
                    <option value="text">普通文本</option>
                    <option value="date">日期</option>
                    <option value="material">化学品类型</option>
                    <option value="check">核查检查项目</option>
                    <option value="organs">机关类型</option>
                    <option value="area">区域类型</option>
                    <option value="data">关联数据</option>
                    <option value="list">列表回填</option>
                </select>
            </td>
            <td>
                <input type="text" id="orgreadonly"/>
            </td>
        </tr>
        <tr>
            <th><span>文本框类型</span> </th>
        </tr>
        <tr>
            <td>
                <select id="orghide">
                    <option value="text">普通文本</option>
                    <option value="hidden">隐藏</option>
                    <option value="button">按钮</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <label for="orgdataname">关联数据</label>
                <textarea class="input-block-level" rows="3" id="orgdataname" placeholder="关联数据..."></textarea>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
var oNode = null,thePlugins = 'text';
window.onload = function() {
    if( UE.plugins[thePlugins].editdom ){
        oNode = UE.plugins[thePlugins].editdom;
		var gValue = '';
		if(oNode.getAttribute('value'))
			gValue = oNode.getAttribute('value').replace(/&quot;/g,"\"");
//        gHidden=oNode.getAttribute('orghide'),
		var gTitle=oNode.getAttribute('title').replace(/&quot;/g,"\""),gHidden=oNode.getAttribute('orghide'),gFontSize=oNode.getAttribute('orgfontsize'),gAlign=oNode.getAttribute('orgalign'),gWidth=oNode.getAttribute('orgwidth'),gHeight=oNode.getAttribute('orgheight'),gType=oNode.getAttribute('orgtype'),gName=oNode.getAttribute('orgnames'),gReadOnly=oNode.getAttribute('orgreadonly'),gDataType=oNode.getAttribute('orgdatatype'),gDataName=oNode.getAttribute('orgdataname');
		gValue = gValue==null ? '' : gValue;
        gTitle = gTitle==null ? '' : gTitle;
        gName = gName==null ? '' : gName;
        gReadOnly = gReadOnly==null ? '' : gReadOnly;
		$G('orgvalue').value = gValue;
        $G('orgname').value = gTitle;
        $G('orgnames').value = gName;
        $G('orgreadonly').value = gReadOnly;
        $G('orghide').value = gHidden;
        $G('orgfontsize').value = gFontSize;
        $G('orgwidth').value = gWidth;
        $G('orgheight').value = gHeight;
        $G('orgalign').value = gAlign;
        $G('orgtype').value = gType;
        $G('orgdatatype').value = gDataType;
        $G('orgdataname').innerHTML = gDataName;
    }
}
dialog.oncancel = function () {
    if( UE.plugins[thePlugins].editdom ) {
        delete UE.plugins[thePlugins].editdom;
    }
};
dialog.onok = function (){
    if($G('orgname').value==''){
        alert('请输入控件名称');
        return false;
    }
    var gValue=$G('orgvalue').value.replace(/\"/g,"&quot;"),gTitle=$G('orgname').value.replace(/\"/g,"&quot;"),gFontSize=$G('orgfontsize').value,gAlign=$G('orgalign').value,gWidth=$G('orgwidth').value,gHeight=$G('orgheight').value,gType=$G('orgtype').value,gDataType=$G('orgdatatype').value,gName=$G('orgnames').value,gReadOnly=$G('orgreadonly').value,gDataName=$G('orgdataname').value,gHide=$G('orghide').value;
    
    if( !oNode ) {
        try {
            gName = gName=='' ? 'leipiNewField' : gName;
            oNode = createElement('input',gName);
            oNode.setAttribute('type','text');
            oNode.setAttribute('title',gTitle);
            oNode.setAttribute('value',gValue);
            oNode.setAttribute('name',gName);
            oNode.setAttribute('leipiPlugins',thePlugins);
            oNode.setAttribute('orgdataname',gDataName);
            oNode.setAttribute('orghide',gHide);
            if( gFontSize != '' ) {
                oNode.style.fontSize = gFontSize + 'px';
                //style += 'font-size:' + gFontSize + 'px;';
                oNode.setAttribute('orgfontsize',gFontSize );
            }
            if( gAlign != '' ) {
                //style += 'text-align:' + gAlign + ';';
                oNode.style.textAlign = gAlign;
                oNode.setAttribute('orgalign',gAlign );
            }
            if( gWidth != '' ) {
                oNode.style.width = gWidth;
                //style += 'width:' + gWidth + 'px;';
                oNode.setAttribute('orgwidth',gWidth );
            }
            if( gHeight != '' ) {
                oNode.style.height = gHeight;
                //style += 'height:' + gHeight + 'px;';
                oNode.setAttribute('orgheight',gHeight );
            }
            if( gType != '' ) {
                oNode.setAttribute('orgtype',gType );
            }
            if( gDataType != '' ) {
                oNode.setAttribute('orgdatatype',gDataType );
            }
            if( gReadOnly != '' ) {
                oNode.setAttribute('orgreadonly',gReadOnly);
            }
//            if( gDataName != '' ) {
//                oNode.setAttribute('orgdataname',gDataName);
//            } else {
//                oNode.setAttribute('orgdataname','');
//            }
            if( gName != 'leipiNewField' ) {
                oNode.setAttribute('orgnames',gName);
            } else {
                oNode.setAttribute('orgnames','');
            }
            //oNode.setAttribute('style',style );
            //oNode.style.cssText=style;//ie7
//            console.log(oNode.outerHTML);
            editor.execCommand('insertHtml',oNode.outerHTML);
        } catch (e) {
            try {
                editor.execCommand('error');
            } catch ( e ) {
                alert('控件异常，请到 [雷劈网] 反馈或寻求帮助！');
            }
            return false;
        }
    } else {
        gName = gName=='' ? 'leipiNewField' : gName;
        gReadOnly = gReadOnly=='' ? '' : gReadOnly;
        oNode.setAttribute('title', gTitle);
        oNode.setAttribute('name',gName);
        oNode.setAttribute('value', $G('orgvalue').value);
        oNode.setAttribute('orgreadonly',gReadOnly );
        oNode.setAttribute('orgdataname',gDataName );
        oNode.setAttribute('orghide',gHide );
        if( gFontSize != '' ) {
            oNode.style.fontSize = gFontSize+ 'px';
            oNode.setAttribute('orgfontsize',gFontSize );
        }else{
            oNode.style.fontSize = '';
            oNode.setAttribute('orgfontsize', '');
        }
        if( gAlign != '' ) {
            oNode.style.textAlign = gAlign;
            oNode.setAttribute('orgalign',gAlign );
        }else{
            oNode.setAttribute('orgalign', '');
        }
        if( gWidth != '' ) {
            oNode.style.width = gWidth;
            oNode.setAttribute('orgwidth',gWidth );
        }else{
            oNode.style.width = '';
            oNode.setAttribute('orgwidth', '');
        }
        if( gHeight != '' ) {
            oNode.style.height = gHeight;
            oNode.setAttribute('orgheight',gHeight );
        }else{
            oNode.style.height = '';
            oNode.setAttribute('orgheight', '');
        }
        if( gType != '' ) {
            oNode.setAttribute('orgtype',gType );
        }else{
            oNode.setAttribute('orgtype', '');
        }
        if( gDataType != '' ) {
            oNode.setAttribute('orgdatatype',gDataType );
        }
//        if( gDataName != '' ) {
//            oNode.setAttribute('orgdataname',gDataName );
//        }
        if( gName != 'leipiNewField' ) {
            oNode.setAttribute('orgnames',gName);
        } else {
            oNode.setAttribute('orgnames','');
        }
        delete UE.plugins[thePlugins].editdom;
    }
};
</script>
</body>
</html>